﻿using System.Linq;
using AB.ServiceDirectory.Commons.DataFilters;
using AB.ServiceDirectory.Dao;
using AB.ServiceDirectory.Entities;

namespace AB.ServiceDirectory.BO
{
    /// <summary>
    /// HSupportingMaterialBO
    /// </summary>
    public sealed class HSupportingMaterialBO
    {
        private static readonly HSupportingMaterialDao Dao = new HSupportingMaterialDao();

        /// <summary>
        /// Prevents a default instance of the <see cref="HSupportingMaterialBO"/> class from being created.
        /// </summary>
        private HSupportingMaterialBO()
        {
        }

        /// <summary>
        /// Gets the supportin material by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public static SupportingMaterial GetSupportingMaterialById(int id)
        {
            return Dao.GetSupportingMaterialById(id);
        }

        /// <summary>
        /// Gets the supporting material.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortType">Type of the sort.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maxRows">The max rows.</param>
        /// <returns></returns>
        public static IQueryable<SupportingMaterial> GetSupportingMaterial(HSupportingMaterialFilter filter,
                                                                           string sortType, int startRowIndex,
                                                                           int maxRows)
        {
            return Dao.GetList(filter, sortType, startRowIndex, maxRows);
        }

        /// <summary>
        /// Gets the organisation count.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public static int GetSupportingMaterialCount(HSupportingMaterialFilter filter)
        {
            return Dao.GetListCount(filter);
        }

        /// <summary>
        /// Gets the type of all supporting material.
        /// </summary>
        /// <returns></returns>
        public static IQueryable SelectSupportingMaterialTypes()
        {
            return Dao.SelectAllSupportingMaterialTypes();
        }

        /// <summary>
        /// Inserts the supporting material.
        /// </summary>
        /// <param name="supportingMaterial">The supporting material.</param>
        /// <returns></returns>
        public static bool InsertSupportingMaterial(SupportingMaterial supportingMaterial)
        {
            return Dao.InsertSupportingMaterial(supportingMaterial);
        }

        /// <summary>
        /// Updates the supporting material.
        /// </summary>
        /// <param name="supportingMaterial">The supporting material.</param>
        /// <returns></returns>
        public static bool UpdateSupportingMaterial(SupportingMaterial supportingMaterial)
        {
            return Dao.UpdateSupportingMaterial(supportingMaterial);
        }

        /// <summary>
        /// Sets the supporting material.
        /// </summary>
        /// <param name="supportingMaterialId">The supporting material id.</param>
        /// <param name="status">if set to <c>true</c> [status].</param>
        public static void SetSupportingMaterial(int supportingMaterialId, bool status)
        {
            Dao.SetSupportingMaterial(supportingMaterialId, status);
        }
    }
}